package com.ywl.study.transaction.config;

import com.ywl.study.transaction.intercept.RequestIntercept;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class HttpConfig implements WebMvcConfigurer {

    @Autowired
    RequestIntercept requestIntercept;

    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(requestIntercept)
                .addPathPatterns("/**")//指定该类拦截的url
                .excludePathPatterns( "/static/**");//过滤静态资源
    }
}
